package org.cloudnote.controller.user;

import org.cloudnote.entity.User;
import org.cloudnote.service.UserService;
import org.cloudnote.util.NoteResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/user")
public class UserLoginController {

    @Autowired
    private UserService userService;

    @RequestMapping("/login.do")
    @ResponseBody
    public NoteResult execute(String name,String password){
        NoteResult noteResult = userService.checkLogin(name, password);
        System.out.println("noteResult = " + noteResult);
        return noteResult;
    }

    @ResponseBody
    @RequestMapping("/regist.do")
    public NoteResult register(String name,String nick,String password){
        NoteResult noteResult = userService.regist(name, password,nick);
        return noteResult;
    }
}
